/* 
 * File:   Assignment8.cpp
 * Author: Allison.Villa
 * 
 * Created on October 1, 2013, 1:31 PM
 */

#include "RegistrationSystem.h"

RegistrationSystem::RegistrationSystem() {
}

RegistrationSystem::~RegistrationSystem() {
}

void RegistrationSystem::run() {
    char action;
    string fName, lName, id;
    bool res;
    double rate, fee;
    string courseName, days, time;
    int semHours;

    // create a Registration object. this is used throughout this class.
    Registration registration;

    printMenu();
    do {
        cout << "What action would you like to perform?\n";
        cin >> action;
        switch (action) {
            case 'A': //Add Student
            case 'a':
                cout << "Please enter the student information to add:\n";
/************************************************************************************
***  ADD your code to add a Student object
***********************************************************************************/
                cout << "First Name: ";
                cin >> fName;
                cout << "Last Name: ";
                cin >> lName;
                cout << "Student ID: ";
                cin >> id;
                cout << "Resident? (Yes=1/No=0): ";
                cin >> res;
                cout << "Rate: ";
                cin >> rate;
                cout << "Fee: ";
                cin >> fee;
                registration.addStudent(fName, lName, id, res, rate, fee);
                break;
            case 'B': //Add Course
            case 'b':
                cout << "Please enter the course information to add:\n";
/************************************************************************************
***  ADD your code to add a Course object
***********************************************************************************/
                cout << "Course Name: ";
                cin >> courseName;
                cout << "Semester Hours: ";
                cin >> semHours;
                cout << "Days: ";
                cin >> days;
                cout << "Time: ";
                cin >> time;
                registration.addCourse(courseName, semHours, days, time);
                break;
            case 'C': //Enroll Student in course
            case 'c':
                cout << "Please enter the student and course information to enroll:\n";
                cout << "Student ID: ";
                cin >> id;
                cout << "Course Name: ";
                cin >> courseName;
                cout << "Days: ";
                cin >> days;
                cout << "Time: ";
                cin >> time;
                registration.enrollCourse(id, courseName, days, time);
                break;
            case 'D': //Cancel Student in course
            case 'd':
                cout << "Please enter the student and course information to cancel:\n";
                cout << "Student ID: ";
                cin >> id;
                cout << "Course Name: ";
                cin >> courseName;
                cout << "Days: ";
                cin >> days;
                cout << "Time: ";
                cin >> time;
                registration.cancelCourse(id, courseName, days, time);
                break;
            case 'L': //List Students
            case 'l':
/************************************************************************************
***  ADD your code to print out the list of Students
***********************************************************************************/
                cout << registration.listStudents();
                break;
            case 'M': //List Courses
            case 'm':
/************************************************************************************
***  ADD your code to print out the list of Courses
***********************************************************************************/
                cout << registration.listCourses();
                break;
            case 'O': //Sort Students
            case 'o':
/************************************************************************************
***  ADD your code to sort the list of Students
***********************************************************************************/
                registration.sortStudents();
                break;
            case 'P': //Sort Courses
            case 'p':
/************************************************************************************
***  ADD your code to sort the list of Courses
***********************************************************************************/
                registration.sortCourses();
                break;
            case 'Q': //Quit
            case 'q':
                return;
            case 'R': //Remove Student
            case 'r':
                cout << "Please enter the Student ID to remove:\n";
/************************************************************************************
***  ADD your code to remove a Student
************************************************************************************/
                cout << "Student ID: ";
                cin >> id;
                registration.removeStudent(id);
                break;
            case 'S': //Remove Course
            case 's':
                cout << "Please enter the course information to remove:\n";
/************************************************************************************
***  ADD your code to remove a Course
************************************************************************************/
                cout << "Course Name: ";
                cin >> courseName;
                cout << "Days: ";
                cin >> days;
                cout << "Time: ";
                cin >> time;
                registration.removeCourse(courseName, days, time);
                break;
            case 'T': //Close Registration
            case 't':
/************************************************************************************
***  ADD your code to close the registration
***********************************************************************************/
                registration.closeRegistration();
                break;
            default:
                cout << "Unknown action\n";
                break;
        }
    } while (1);
}

void RegistrationSystem::printMenu() {
    cout << "Choice\t\tAction\n" <<
            "------\t\t------\n" <<
            "A\t\tAdd Student\n" <<
            "B\t\tAdd Course\n" <<
            "C\t\tEnroll Student in Course\n" <<
            "D\t\tCancel Student in Course\n" <<
            "L\t\tList Students\n" <<
            "M\t\tList Courses\n" <<
            "O\t\tSort Students\n" <<
            "P\t\tSort Courses\n" <<
            "Q\t\tQuit\n" <<
            "R\t\tRemove Student\n" <<
            "S\t\tRemove Course\n" <<
            "T\t\tClose Registration\n";
}

